var param = '0'; // indicate the current page. m = ulist

// When DOM is ready
$(function() {
	
	// load the main page
	$('#content').html('<img src="assets/img/ajax-loader.gif">');
	$('#content').load('pages/view_part/list', function() {
		param = '0';
		getData();
	});
	
});

$(function(){
	$('input:text').each(function(){
		var txtval = $(this).val();
		$(this).focus(function(){
			$(this).val('');
		});
		$(this).blur(function(){
			if($(this).val() == ""){
				$(this).val(txtval);
			}
		});
	});
});

/*
 *  Display alerts
 */
function display_alert(string, selector, kind)
{
        $(selector).html('<div class="alert alert-'+kind+' fade in" data-alert>'
        + '<strong>Message :</strong> ' + string
        + '</div>');
        $(".alert").alert();
        window.setTimeout(function() { $(".alert").alert('close').fadeOut('slow'); }, 2000);
}


// Adujst the height
var topDivHeight = $("#header").height(),
bottomDivHeight = $('#footer').height(),
totalHeight = $(document).height();
$('#main').height(totalHeight  - topDivHeight - bottomDivHeight - 40);
var mainDivHeight = $("#main").height();

function set_height(selector)
{
	var topDivHeight = $("#header").height(),
	bottomDivHeight = $('#footer').height(),
	main_headerDivHeight = $('#main_header').height(),
	totalHeight = $(document).height(),
	divHeight = totalHeight - topDivHeight - 170 - bottomDivHeight
	$(selector).height(divHeight);
	$(selector).css("max-height:" + divHeight);
}

/*
 *  Switch interface
 */
function switchInterface(mode)
{
	if(mode == 'map')
	{
		if($('#map').hasClass('span4'))
		{
			$('#map').toggleClass('span8');
			$('#map').toggleClass('span4');	
		
			$('#content').toggleClass('span8');
			$('#content').toggleClass('span4');
		}
	}
	else if(mode == 'content')
	{
		if($('#content').hasClass('span4'))
		{
			$('#map').toggleClass('span8');
			$('#map').toggleClass('span4');
			
			$('#content').toggleClass('span8');
			$('#content').toggleClass('span4');	
			
			if($('#add_object_button').html() == 'Cancel')
				{ cancelRegistration();}
		}
	}
	else
	{
		$('#content').toggleClass('span8');
		$('#content').toggleClass('span4');
		
		$('#map').toggleClass('span8');
		$('#map').toggleClass('span4');
	}
}

/*
 * Interface related
 */



